package cn.com.homeyoda.aimate.aihealth.ui.game.record;

import android.app.Application;
import android.util.Log;

import androidx.annotation.NonNull;

import cn.com.homeyoda.aimate.aihealth.R;
import cn.com.homeyoda.aimate.aihealth.base.BaseViewModel;
import cn.com.homeyoda.aimate.aihealth.bean.KePuBean;
import cn.com.homeyoda.aimate.aihealth.bean.MessageTitleBean;
import cn.com.homeyoda.aimate.aihealth.data.Repository;
import cn.com.homeyoda.aimate.aihealth.ui.game.GameBean;
import cn.com.homeyoda.aimate.aihealth.ui.my.ActivityBean;
import com.wzq.mvvmsmart.event.StateLiveData;

import java.util.ArrayList;
import java.util.List;

public class GameRecordViewModel extends BaseViewModel<Repository> {

    private List<GameBean> gameRecordList = new ArrayList<>();
    public StateLiveData<List<GameBean>> gameRecordData;
    public StateLiveData<List<MessageTitleBean>> titleData;


    public GameRecordViewModel(@NonNull Application application, Repository model) {
        super(application, model);
        titleData = new StateLiveData<>();
        titleData.setValue(new ArrayList<>());
        gameRecordData = new StateLiveData<>();
        gameRecordData.setValue(new ArrayList<>());
    }

    public void titleData() {
        List<MessageTitleBean> titleBeanList = new ArrayList<>();
        MessageTitleBean titleBean = new MessageTitleBean();
        titleBean.setTitle("全部");
        MessageTitleBean titleBean1 = new MessageTitleBean();
        titleBean1.setTitle("皮肤病类型");
        MessageTitleBean titleBean2 = new MessageTitleBean();
        titleBean2.setTitle("饮食知识类型");
        MessageTitleBean titleBean3 = new MessageTitleBean();
        titleBean3.setTitle("运动知识类型");
        MessageTitleBean titleBean4 = new MessageTitleBean();
        titleBean4.setTitle("身心健康类型");

        titleBeanList.add(titleBean);
        titleBeanList.add(titleBean1);
        titleBeanList.add(titleBean2);
        titleBeanList.add(titleBean3);
        titleBeanList.add(titleBean4);
        titleData.postSuccess();
        titleData.getValue().addAll(titleBeanList);
    }

    public void getGameRecordDataByType(int type) {
        List<GameBean> list = new ArrayList<>();
        if (type == 0) {
            list.addAll(gameRecordList);
        } else {
            for (GameBean game : gameRecordList) {
                if (game.getType() == type) {
                    list.add(game);
                }
            }
        }
        gameRecordData.getValue().clear();
        gameRecordData.postSuccess();
        gameRecordData.getValue().addAll(list);
        gameRecordData.postValueAndSuccess(gameRecordData.getValue());
    }

    public void getGameRecordData() {
        gameRecordList.add(new GameBean("皮肤病知识问答", R.mipmap.ic_game_circle1, 1, "2021-03-05", 10));
        gameRecordList.add(new GameBean("饮食知识问答", R.mipmap.ic_game_circle2, 2, "2022-07-21", 8));
        gameRecordList.add(new GameBean("运动知识问答", R.mipmap.ic_game_circle3, 3, "2023-06-19", 9));
        gameRecordList.add(new GameBean("身心健康知识问答", R.mipmap.ic_game_circle4, 4, "2024-08-23", 7));
        gameRecordList.add(new GameBean("身心健康知识问答", R.mipmap.ic_game_circle5, 5, "2025-03-03", 6));
        gameRecordData.postSuccess();
        gameRecordData.getValue().addAll(gameRecordList);
        gameRecordData.postValueAndSuccess(gameRecordData.getValue());
    }
}
